<script type="text/javascript" src="/plugins/layer/layer.js"></script>
<script>
    function show_wait_sendgoods_stock_list_100(url,title){
        layer.open({
            type: 2,
            title: title,
            shadeClose: true,
            shade: 0.8,
            area: ['100%', '100%'],
            btn: ['关闭窗口'], //按钮
            content:url
        });
    }
    function show_wait_sendgoods_stock_list_90(url,title){
        layer.open({
            type: 2,
            title: title,
            shadeClose: true,
            shade: 0.8,
            area: ['90%', '90%'],
            btn: ['关闭窗口'], //按钮
            content:url
        });
    }
    /*layer 弹窗*/
    function showChoosePics(url,title){
            layer.open({
                type: 2,
                title: title,
                shadeClose: true,
                shade: 0.8,
                area: ['800px', '500px'],
                /*btn: ['关闭窗口'], //按钮*/
                content:url,
            });
    }
    
    /***
     * 图片数组 生成选择图片预览
     * @param data_arry  图片数据数组
     * @param data_arry_length 图片数据数组长度
     * @private
     */
    function _getSelectedPic(data_arry,data_arry_length,only_choose_one,dom_id,is_need_watch_pic){
        //<div class="pics_wrp js_guige_images_unitymain">
        //    <div class="edit_pic_wrp">
        //        <img src="/Public/Admin/themes/images/img14.png">
        //
        //        <div class="edit_pic_mask">
        //         <a href="javascript:;" class="icon18_common del_gray js_delete"></a>
        //        </div>
        //    </div>
        //</div>
        var _dom_id= dom_id;
        
        for(var i=0;i<data_arry_length;i++){
        	dom_id = _dom_id;
            var img_src = data_arry[i]['src'];
            var img_id  = data_arry[i]['id'];
        	var haveSelected_len = $('input[name=is_first]:checked').length;
            var _checked='';
            if( haveSelected_len === 0 ){
            	_checked='checked';
            }

            var hide_style='';
            if(typeof  only_choose_one !=='undefined' && only_choose_one.length!==0){
            	hide_style=' style="display:none;" ';
            }
            
            var id ="file_"+img_id;

            var pic_name='pic[]';
            if(typeof dom_id === 'undefined' || dom_id.length===0  ){
            	if($('#'+$.trim(id)).length>0)continue;
            	dom_id='.upload_preview';
            }else{
            	if($('#'+dom_id+' #'+$.trim(id)).length>0)continue;
            	pic_name=dom_id+'_pic[]';
            	dom_id='#'+dom_id;
            }
            console.log(img_src);
            var btn_del = '<a href="javascript:;" title="点击移除" class="icon18_common del_gray js_delete" onclick="removeThisSelected(this);"></a>';
            var btn_watch = '';
            if( typeof(is_need_watch_pic) !== 'undefined' || is_need_watch_pic.length == 0 ){
            	var img_path = img_src.replace('/attas/orgimg/','');
            		img_path = img_path.replace('/attas/','');
            	btn_watch ='<a href="goods.php?act=show_image&img_url='+img_path+'" title="查看原图" target="_blank" class="icon18_common search_gray js_delete"></a>';
            }
            
            
            var _pic_html='<div class="pics_wrp js_guige_images_unitymain" id="'+$.trim(id)+'" >' +
                '<div class="edit_pic_wrp">';
            _pic_html+='<img src="'+img_src+'">';
            _pic_html+='<div class="edit_pic_mask" >' + btn_del + btn_watch +
            '<input type="hidden" name="'+pic_name+'" value="'+img_id+'" />' +
            '</div>' +
            '</div>' +
            '</div>';

            if(typeof  only_choose_one !=='undefined' && only_choose_one.length!==0 ){
                $(dom_id).html(_pic_html);
            }else{
                $(dom_id).append(_pic_html);
            }

        }
    }
    
    /**
     * 移除选中的图片
     * @param obj
     */
    function removeThisSelected(obj){
    	//询问框
    	layer.confirm('您确定要移除吗?', {
    	    btn: ['确定','取消'] //按钮
    	}, function(){
    	    /*layer.msg('的确很重要', {icon: 1});*/
    		$(obj).parent().parent().parent().remove();
    		//先移除，通过ajax后台请求控制器改变data_id;
            /*$.ajax({
                url:_data_id_url,
                data:{'id':$(obj).find('input').val()},
                type:'POST',
                dataType:'json',
                success:function(data){
                    $(obj).parent().parent().remove();
                },
                error:function(){

                },complete:function(){

                }
            });*/
            layer.closeAll();
    	}, function(){
    	    /*layer.msg('也可以这样', {
    	        time: 20000, //20s后自动关闭
    	        btn: ['明白了', '知道了']
    	    });*/
    		layer.closeAll();
    	});
    }
</script>